package com.msb.controller;

import com.msb.service.ExceptionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.servlet.ModelAndView;

/**
 * @author sunpeng
 * @Date 2021-06-07 16:02
 */
@Controller
public class ExceptionController {

    @Autowired
    private ExceptionService exceptionService;

    @GetMapping("/test1")
    public String text1(){
        int i = 1/0;
        return "success";
    }
    @GetMapping("/test2")
    public String text2(){
        String str = null;
        int length = str.length();
        return "success";
    }
    @GetMapping("/test3")
    public String text3(){
        exceptionService.text3();
        return "success";
    }

/*    @ExceptionHandler(value ={ArithmeticException.class,NullPointerException.class} )
    public ModelAndView handelException(){
        ModelAndView mv =new ModelAndView();
        mv.setViewName("error1.jsp");
        return mv;
    }*/


}
